Skip to content

New Extension Methods#2

Merged
Blogbotana merged 9 commits into
mainfrom
feature/new_api
Mar 16, 2026
Merged

New Extension Methods#2
Blogbotana merged 9 commits into
mainfrom
feature/new_api

Conversation

@Blogbotana

Copy link
Copy Markdown
Member

No description provided.

Blogbotana and others added 5 commits March 14, 2026 18:46
DrawSession:
- Add DrawSolid() — renders Solid faces as PositionNormal triangles with
  ambient/diffuse lighting, tessellates edges as lines. Supports transparency
  (0.0–1.0) with correct opaque/transparent pass handling.
- Add DrawMesh() — renders Mesh as flat-shaded triangles with per-triangle
  normals computed from cross product.
- Split GPU buffers into _lineBuffers (Position+LineList) and _triBuffers
  (PositionNormal+TriangleList) for independent pipeline paths.
- UseInTransparentPass() returns true when any solid has transparency > 0.
- RenderScene() handles both passes: opaque (lines + solid faces) and
  transparent (transparent faces only).
- CanExecute() and ComputeOutline() account for all three primitive lists.
- Clear() clears lines, solids and meshes.
- Fix: Remove auto-registration from constructor — registration is now
  explicit via RegisterDrawSession() or Register().
- Fix: VertexBuffer/IndexBuffer.Map(0) → Map(actualSize) — Map() takes
  buffer size in floats/shorts, not an offset. Passing 0 wrote no data.

UIControlledApplicationExtensions:
- Add RegisterDrawSession() extension on UIControlledApplication.
  Encapsulates correct DirectContext3D registration order per Revit API docs:
  AddServer → GetActiveServerIds → Contains check → SetActiveServers.
  Replaces ~10 lines of boilerplate with a single call in OnStartup.

Docs:
- README: Add DrawSession and DrawExtensions usage sections with full examples.
- CLAUDE.md: Add DrawSession section covering registration pattern,
  UIApplication lifecycle, fixed bugs, CanExecute conditions, threading model.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix black faces: pre-compute all triangle data (Triangulate, ComputeNormal)
  in DrawSolid/DrawMesh on the main thread instead of calling Revit geometry
  API from the render thread (where it silently fails, producing zero normals)
- Replace _solids/_meshes raw storage with _triData (pre-computed tuples)
- Add DrawBox(XYZ min, XYZ max), DrawBox(BoundingBoxXYZ), DrawBox(Outline):
  filled axis-aligned box with 12 wireframe edges, pure math triangulation
- Add DrawSphere(XYZ center, double radius): UV sphere (16x32 rings) with
  3 great-circle wireframe edges, pure math triangulation
- Rename private DrawBox helper to DrawWireBox to avoid name conflict

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…DotNet

- Replace stroke-font approach with GraphicsPath.AddString() → Flatten() → LibTessDotNet
  tessellation so any system font renders as filled triangles (handles holes in O, A, B, D, etc.)
- Add _textCache static dict: normalised (height=1.0, Y-up) triangles cached per (text, fontFamily)
- Add BuildTextTriangles / ExtractContours / GetFontFamily private helpers
- Remove AppendThickSegment and _strokeFont dictionary (old stroke-font code)
- Add DrawPoint(XYZ, string label, ...) overload: cross + DrawText label
- Add DrawBox(min,max) / DrawBox(BoundingBoxXYZ) / DrawBox(Outline) — pure-math box triangulation
- Add DrawSphere(center, radius) — UV-sphere 16×32 tessellation, no Revit geometry API calls
- Add DrawSolid / DrawMesh with main-thread pre-computed triangles (fixes black faces on render thread)
- Add LibTessDotNet v1.1.0 + System.Drawing.Common v8.0.0 (net8) / System.Drawing ref (net4x)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Blogbotana Blogbotana marked this pull request as ready for review March 16, 2026 21:34
…uGet pack

- Add DrawSolid, DrawMesh, DrawBox, DrawSphere, DrawText sections with code examples
- Add full method reference table for DrawSession
- Add color reference table
- Drop Revit 2027 from supported versions list
- Fix NU5019: icon.png path in csproj was pointing to repo root instead of project folder

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Blogbotana Blogbotana merged commit 96b98df into main Mar 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant